var windowName = "fileInfoSum";
apiready = function(){
    onWindowShow(function () {
    })
    onWindowHide(function () {
    })
    console.log("index page is OK");
    var imageBrowser = api.require('imageBrowser');
    var Page = createVM("#Page",{
        //页面数据
        index:1
        ,sites:[]
        ,files:[]
        ,logs:[]
        ,info:{}

    },{
        //页面方法
        "init":function () {
            var data = getData4Page()
            var _this  = this;
            console.log(data);
            logJson(data,"data:")
            this.id = data.id;
            showLoading()
            apiGet("/app/file/info/sum", {id:data.id}, function (res) {
                clearLoading();
                _this.sites = res.data.sites
                _this.files = res.data.files
                _this.logs = res.data.logs
                _this.info = res.data.info
            });
        }
        ,"show":function (index) {
            this.index = index
        }
        ,saveFile:function (url) {
            log(url)
        }
        ,showPic:function (index) {
            var pic = this.files[index].FileFile_file
            imageBrowser.openImages({
                imageUrls: [pic],
                activeIndex:0
            });
        }
        ,showPics:function (index,pics) {
            imageBrowser.openImages({
                imageUrls: pics,
                activeIndex:index
            });
        }
        ,download:function (url) {
            showToast("开始下载")
            var path = "/storage/emulated/0/qzyt/" + random_string() + get_suffix(url);
            api.download({
                url: url,
                savePath: path,
            }, function(ret, err) {
                logJson(ret)
                logJson(err)
                if (ret.state == 1) {
                    //下载成功
                    showToast("下载成功")
                } else {

                }
            });
        }
    })

    Page.init()

}

